#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
int main()
{
  int fds[2];
  char buf[50];
  int len;
  if(pipe(fds)==-1)
  {
    perror("make pipe");
    exit(1);
  }

  //read from stdin
  while(fgets(buf,50,stdin))
  {
    len=strlen(buf);

    //write into pipe 
    if(write(fds[1],buf,len)!=len)
    {
      perror("write to pipe");
      break;
    }
    memset(buf,'0',sizeof(buf));

    //read from pipe 
    if((len=read(fds[0],buf,50))==-1)
    {
      perror("read from pipe");
      break;
    }

    //write to stdout
    if(write(1,buf,len)!=len)
    {
      perror("write to stdout");
      break;
    }
  }
  return 0;
}
